[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
A_MINUS()
Subtract all elements of an array by a value or an array of values
-------------------------------------------------------------------------------
Syntax
A_MINUS( <aTarget>,
<nValue> | <aValue>,
[<aSource>] )
Arguments
<aTarget> is the array to be modified. If <aSource> is not
specified then each element of <aTarget> will be subtracted by the
<nValue> or element by element by <aValue>.
<nValue> or <aValue> is either a value or an array of values to be
subtracted.
<aSource> is an optional array of values. If specified, then each
element of <aTarget> will be filled with the corresponding value
in <aSource> subtracted by <aValue> or <nValue>.
Returns
Although there is no return value, the <aTarget> array is modified.
Description
A_MINUS() provides a means to perform a subtraction of every
element in the <aSource> array if specified or the <aTarget> array
if not. Each element of the <aSource> or <aTarget> array has
<nValue> or <aValue> subtracted from it. The result of the
subtraction replaces the value in the <aTarget> array.
A_MINUS() can be performed on any integer or floating point type
array. These include the (T)iny, (I)nteger, (L)ong, (F)loat and
(D)ouble. Mixing of these types is allowed.
Notes
If the <aTarget> and the <aSource> arrays are not the same
dimensions, the results will be a subtraction element for element
as the arrays are aligned in memory. See chapter two for how
arrays are aligned in memory.
Examples
// Declare three double type arrays for this function.
LOCAL rows, cols
rows = 10
cols = 20
aSource = A_DECLARE( "D", rows, cols )
aTarget = A_DECLARE( "D", rows, cols )
aSubMe = A_DECLARE( "D", rows, cols )
// Fill the target array with 10's
A_FILL( aTarget, 10, A_(1, 1), rows * cols )
// Subtract 2 from every element in the target array
A_MINUS( aTarget, 2 )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 8.0
// Fill the source array with 10's
A_FILL( aSource, 10, A_(1, 1), rows * cols )
// Subtract five from every element in the source array and
// put the result in the target array.
A_MINUS( aTarget, 5, aSource )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 5.0
// Fill the "subtract me" array with 4's
// Remember the source array still has all 10's
A_FILL( aSubMe, 4, A_(1, 1), rows * cols )
// Subtract from every element in the source array the
// value in every matching element of the "subtract me"
// array and put the result in the target array.
A_MINUS( aTarget, aSubMe, aSource )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 6.0
See Also:
A_MULTIPLY()
A_PLUS()
A_DIVIDE()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson